<?php

namespace common\models\actor;

use common\helpers\Url;
use Yii;
use common\db\ActiveRecord;

/**
 * This is the model class for table "{{%actor_attach}}".
 *
 * @property int $id
 * @property int $user_id 用户ID
 * @property int $actor_id 演员ID
 * @property string $path 路径
 * @property string $description 描述
 * @property int $image 附件类型：1图片，0文件
 * @property int $status 状态
 * @property int $created_at
 * @property int $updated_at
 */
class ActorAttach extends ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%actor_attach}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['user_id', 'actor_id', 'image', 'status', 'created_at', 'updated_at'], 'integer'],
            [['user_id', 'path'], 'required'],
            [['path', 'description'], 'string', 'max' => 255],
            ['actor_id', 'safe']
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_id' => 'User ID',
            'actor_id' => 'Actor ID',
            'path' => 'Path',
            'description' => 'Description',
            'image' => 'Image',
            'status' => 'Status',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function fields()
    {
        return [
            'id',
            'path' => function () {
                return Url::attach($this->path);
            },
            'description',
            'image',
        ];
    }
}
